package router

import (
	"my-yipuku/controllers"
	"my-yipuku/middleware"

	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.Default()
	r.POST("/login", controllers.LoginControoler{}.Login)        // 账号登陆
	r.POST("/login/code", controllers.LoginControoler{}.SendSms) // 手机验证码

	// 登录模块
	login := r.Group("/").Use(middleware.LoginAuth())
	{
		login.POST("/login_out", controllers.LoginControoler{}.LoginOut) // 退出登陆
	}

	// User模块
	user := r.Group("/").Use(middleware.LoginAuth())
	{
		user.GET("/info", controllers.UserController{}.Info)                   // 获取用户信息
		user.POST("/update/myInfo", controllers.UserController{}.UpdateMyInfo) // 个人信息修改
	}

	// 兑换卷
	coupon := r.Group("/coupon").Use(middleware.LoginAuth())
	{
		coupon.GET("/list", controllers.Coupon{}.List)
		coupon.POST("/buy", controllers.Coupon{}.Buy)
	}
	return r
}
